package com.maimao.search.model.goods;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.NumberDeserializers;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.UnexpectedTypeException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * es商品模型
 *
 * @author MaoLin Wang
 * @date 2020/12/27 11:52 上午
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EsGoods implements Serializable {


    private static final long serialVersionUID = -7287865118527107489L;

    /**
     * 解决前端Long精度丢失
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @JsonDeserialize(using = NumberDeserializers.LongDeserializer.class)
    private Long id;
    /**
     * 要搜索的内容 包括商品的名字、关键词、所在的分类名、品牌名
     */
    private String key;

    private Integer sellCount;

    /**
     * 搜索提示 格式： { input: [商品关键词分隔组成的列表], weight: 10 }
     */
    private Map<String, Object> suggestions;

    private String subName;

    private Long brandId;

    private Integer cid1;
    private Integer cid2;

    private Integer cid3;

    private Long shopId;
    private String shopName;

    private LocalDateTime createTime;

    /**
     * 用于价格搜索
     */
    private List<BigDecimal> priceList;

    /**
     * sku信息 json列表字符串
     */
    private String goodsSkus;

    /**
     * 支持搜索的参数 key:参数名 value：参数值
     */
    private Map<String, Object> searchParams;

    @Override
    public String toString() {
        return "EsGoods{" +
                "id=" + id +
                ", key='" + key + '\'' +
                ", suggestions=" + suggestions +
                ", subName='" + subName + '\'' +
                ", brandId=" + brandId +
                ", cid1=" + cid1 +
                ", cid2=" + cid2 +
                ", cid3=" + cid3 +
                ", shopName=" + shopName +
                ", shopId=" + shopId +
                ", createTime=" + createTime +
                ", priceList=" + priceList +
                ", goodsSkus='" + goodsSkus + '\'' +
                ", searchParams=" + searchParams +
                '}';
    }
}
